<template>
  <div class="centreLeft1">
    <div class="bg-color-black">
      <div class="d-flex pt-2 pl-2">
        <span>
          <i class="iconfont icon-chart-pie-alt" />
        </span>
        <div class="d-flex">
          <span class="fs-xxl text mx-2">学生选课</span>
          <dv-decoration-3 class="dv-dec-3" :color="datavColors"/>
        </div>
      </div>
      <div class="d-flex jc-center">
        <dv-scroll-ranking-board :config="config"  class="dv-scr-rank-board" />
      </div>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent,computed, reactive, onMounted } from 'vue'
import { useStore } from 'vuex'
import { elective } from '@/public/request/http'
export default defineComponent({
  components: {
  },
  setup() {
    const datavColors = computed(() => useStore().state.datavColors)
    let config = reactive({
      data:[],
      unit: '人'
    })

    // methods
    const setData = async () => {
      const res = await elective()
      config.data = []
      res.forEach(element => {
        config.data.push({name:element.courseName,value:element.totalCount})
      });
    }

    onMounted(()=>{
      setData()
    })

    return { 
      config,
      datavColors
    }
  }
})
</script>

<style lang="scss" scoped>
$box-width: 100%;
$box-height: 350px;

.centreLeft1 {
  padding: 5px;
  height: $box-height;
  width: $box-width;
  border-radius: 5px;
  .bg-color-black {
    padding: 5px;
    height: $box-height;
    width: $box-width;
    border-radius: 10px;
  }
  .text {
    color: #c3cbde;
  }
  .dv-dec-3 {
    position: relative;
    width: 100px;
    height: 20px;
    top: -3px;
  }

  .bottom-data {
    .item-box {
      & > div {
        padding-right: 5px;
      }
      font-size: 14px;
      float: right;
      position: relative;
      width: 50%;
      color: #d3d6dd;
      .dv-digital-flop {
        width: 120px;
        height: 30px;
      }
      i {
        font-size: 20px;
        line-height: 30px;
        margin-left: 20px;
      }
      .colorYellow {
        color: yellowgreen;
      }
      p {
        text-align: center;
      }
    }
  }
  .dv-scr-rank-board {
      width:100%;
      height:320px;
      padding: 0 10px;
  }
}
</style>
